<template name="aggregatePipeline">
    {{#if isConnected}}
        {{> pageHeading title=getPageHeading }}
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>{{_ "drag_stages"}}
                            </h5>
                            <div class="ibox-tools">
                                <button id="btnShowFinalizedQuery" type="button"
                                        style="margin-right: 5px;"
                                        class="btn btn-sm btn-primary ladda-button fix-button" data-style="contract">
                                    {{_ "show_query"}}
                                </button>
                                <button id="btnAggregateHistory" type="button"
                                        style="margin-right: 5px;"
                                        class="btn btn-sm btn-primary ladda-button fix-button" data-style="contract">
                                    {{_ "history"}}
                                </button>
                                <button id="btnExecuteAggregatePipeline" type="button"
                                        class="btn btn-sm btn-primary ladda-button fix-button" data-style="contract">
                                    {{_ "execute"}}
                                </button>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <form class="form-horizontal">
                                <div class="form-group">
                                    <label class="col-lg-1 control-label">{{_ "collection"}}</label>
                                    <div class="col-lg-11">
                                        <select id="cmbCollectionsAggregate"
                                                data-placeholder="{{_ "select_collection"}}"
                                                class="chosen-select form-control"
                                                tabindex="-1">
                                            <option></option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-lg-1 control-label">{{_ "choose_stage"}}</label>
                                    <div class="col-lg-11">
                                        <select id="cmbStageQueries"
                                                data-placeholder="{{_ "choose_stage"}}"
                                                class="chosen-select form-control"
                                                tabindex="-1">
                                            <option></option>
                                            <option>addFields</option>
                                            <option>bucket</option>
                                            <option>bucketAuto</option>
                                            <option>collStats</option>
                                            <option>count</option>
                                            <option>currentOp</option>
                                            <option>facet</option>
                                            <option>geoNear</option>
                                            <option>graphLookup</option>
                                            <option>group</option>
                                            <option>indexStats</option>
                                            <option>limit</option>
                                            <option>lookup</option>
                                            <option>match</option>
                                            <option>out</option>
                                            <option>project</option>
                                            <option>redact</option>
                                            <option>replaceRoot</option>
                                            <option>sample</option>
                                            <option>skip</option>
                                            <option>sort</option>
                                            <option>sortByCount</option>
                                            <option>unwind</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-lg-1 control-label">{{_ "pipeline"}}</label>
                                    <ul class="sortable-list agile-list col-lg-11" id="stages">
                                    </ul>
                                </div>

                                <ul id="resultTabs" class="nav nav-tabs">
                                </ul>
                                <div id="resultTabContents" class="tab-content">
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        {{> aggregateHistories}}

        <!-- MODAL show query-->
        <div class="modal inmodal" id="showQueryModal" tabindex="-1" role="dialog" aria-hidden="true" style="display: none;">
            <div class="modal-dialog">
                <div class="modal-content animated bounceInRight">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">
                            <span aria-hidden="true">×</span>
                            <span class="sr-only">{{_ "close"}}</span>
                        </button>
                        <h4 class="modal-title">{{_ "finalized_aggregation_query"}}</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div id="jsonEditorOfFinalizedQuery" style="width: 100%;height:500px" class="col-lg-12">
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button id="btnCloseShowQuery" type="button" class="btn btn-outline btn-primary btn-block ladda-button"
                                data-dismiss="modal">{{_ "close"}}
                        </button>
                    </div>
                </div>
            </div>
        </div>

    {{/if}}
</template>
